<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>过滤器</title>
  <script src="../vue.js"></script>
</head>
<body>
  <div id="root">
    {{gender | gender}}
  </div>
  <script type="module">
    Vue.config.productionTip = false

    import './filters.js'
    var vm = new Vue({
      el: '#root',
      data: {
        gender: 0
      },
      computed: {
        filterGender() {
          return this.gender === 0 ? '男' : '女'
        }
      },
      filters: {
        f(gender, arg1) {
          return (gender === 0 ? '男' : '女') + arg1
        },
        f2(result, arg1) {
          return result + arg1
        }
      },
      mounted() {
        this.gender = 1
      },
    })
  </script>
</body>
</html>